/*
 * Copyright (c) 2017 Baidu, Inc. All Rights Reserve.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.baidu.fsg.uid.worker.entity;

import com.baidu.fsg.uid.worker.WorkerNodeType;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import me.boot.gen.table.annotation.ColumnComment;
import me.boot.gen.table.annotation.IsAutoIncrement;
import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

import java.time.LocalDate;
import java.time.LocalDateTime;

/**
 * Entity for M_WORKER_NODE
 *
 * @author yutianbao
 */
@Data
@TableName(WorkerNode.TABLE_NAME)
public class WorkerNode {
    public final static String TABLE_NAME = "worker_node";

    /**
     * Entity unique id (table unique)
     */
    @IsAutoIncrement
    @ColumnComment("唯一编码")
    @TableId(type = IdType.AUTO)
    private Long id;

    /**
     * type是CONTAINER（容器）: 主机名, ACTUAL（实际机器） : IP.
     */
    @ColumnComment("当type是CONTAINER（容器）: 主机名; 当type是 ACTUAL（实际机器） : IP")
    @TableField
    private String hostName;

    /**
     * type是CONTAINER（容器）： Port, ACTUAL（实际机器） : 时间戳 + 随机数(0-10000)
     */
    @ColumnComment("当type是CONTAINER（容器）： Port, 当type是 ACTUAL（实际机器） : 时间戳 + 随机数(0-10000)")
    @TableField
    private String port;

    /**
     * type of {@link WorkerNodeType}
     */
    @ColumnComment("终端节点类型  1--容器  2--实际机器")
    @TableField
    private Integer type;

    /**
     * Worker launch date, default now
     */
    @ColumnComment("发起时间")
    @TableField
    private LocalDate launchDate = LocalDate.now();

    /**
     * Created time
     */
    @ColumnComment("创建时间")
    @TableField
    private LocalDateTime createTime = LocalDateTime.now();

    /**
     * Last modified
     */
    @ColumnComment("最后修改时间")
    @TableField
    private LocalDateTime updateTime = LocalDateTime.now();


    @Override
    public String toString() {
        return ReflectionToStringBuilder.toString(this, ToStringStyle.SHORT_PREFIX_STYLE);
    }

}
